<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>  
	<script type="text/javascript">
	  $(document).ready(function(){
		  
	   });
	  
	  function insert(){
	        $.ligerDialog.open({ url: 'web/top/insert.do', height: 300, width: 400, buttons: [
	            { text: '确定', onclick: function (item, dialog) {
	            	dialog.frame.$("form:first").submit();
	            },cls:'l-dialog-btn-highlight' },
	            { text: '取消', onclick: function (item, dialog) { dialog.close(); } }
	         ], isResize: true,title:'新增'
	        });
	    }
	  function editItem(id){
	        $.ligerDialog.open({ url: 'web/top/update.do?id='+id, height: 300, width: 400, buttons: [
	            { text: '确定', onclick: function (item, dialog) {
	            	dialog.frame.$("form:first").submit();
	            },cls:'l-dialog-btn-highlight' },
	            { text: '取消', onclick: function (item, dialog) { dialog.close(); } }
	         ], isResize: true,title:'编辑'
	        });
	    }
	  function applyItem(id){
		  $.ligerDialog.confirm('是否应用此项目？', function (yes) {
			var url = "<%=basePath%>web/top/apply.do";
			if(yes){
				$.post(url,{'id':id},function(data){
					var result = eval('(' + data + ')');
					if(result.code==1){
						location.href = "<%=basePath%>web/top/list.do";
					}else{
						$.ligerDialog.error(result.message);
					}
				})
			}  
		  });
	    }
	  function deleteItem(id){
		  $.ligerDialog.confirm('是否删除此项目？', function (yes) {
				var url = "<%=basePath%>web/top/delete.do";
				if(yes){
					$.post(url,{'id':id},function(data){
						var result = eval('(' + data + ')');
						if(result.code==1){
							location.href = "<%=basePath%>web/top/list.do";
						}else{
							$.ligerDialog.error(result.message);
						}
					})
				}  
			  });
	  }
	 
	</script>
	
</head>

<body>
	<div style="width: 100%;" >
	<form action="web/top/list.do" method="post" name="topForm" ></form>
		<table id="imageTable" border="0" cellspacing="0" cellpadding="0" width="100%" class="ld-datagrid">
			<tr>
				<th>序号</th>
				<th>主题</th>
				<th>图片名称</th>
				<th>备注</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${list }" var="item" varStatus="status" >
				<tr>
					<td>${status.count}</td>
					<td>${item.name }</td>
					<td><a href="http://localhost:38080/w/top/${item.url }" target="_blank" >${item.url }</a></td>
					<td>${item.memo }</td>
					<td>
						<c:if test="${item.status == 0 }">未应用</c:if>
						<c:if test="${item.status == 1 }">已应用</c:if>	
					</td>
					<td>
						<input type="button" value="应用" class="ldBtnLink" onclick="applyItem('${item.id}');" />
						<input type="button" value="编辑" class="ldBtnLink" onclick="editItem('${item.id}');" />
						<input type="button" value="删除" class="ldBtnLink" onclick="deleteItem('${item.id}');" />
					</td>
				</tr>	
			</c:forEach>
		</table>
	</div>
		<hr/>
	<div>
		<div style="float: left;">
			<input type="button" value="新增"   id="btn_insert" onclick="insert()" class="ldBtnGray" />
		</div>
		<div style="float: right;">
			<form id="pagerForm" method="post" name="pagerForm" style="text-align: right;" action="web/top/list.do">
				<jt:pager action="pagerForm" />
			</form>
		</div>
	</div>
</body>
</html>
    